//
// Created by xili on 2024/8/9 21:21.
// Go big or go home.
//
#include "leetcode.h"

class Solution {
public:
    int maxFrequencyElements(vector<int> &nums) {
        unordered_map<int, int> um;
        for (auto &item: nums) {
            um[item]++;
        }
        int ans = 0;
        int mx;
        for (auto &[num, cnt]: um) {
            if (cnt > mx) {
                ans = cnt;
                mx = cnt;
            } else if (cnt == mx) {
                ans += cnt;
            }
        }
        return ans;
    }
};